package com.jalarbee.core.spring;

import javax.naming.NamingException;

import org.apache.log4j.Logger;
import org.springframework.jndi.JndiTemplate;

public class JndiSupport {

	private JndiTemplate jndiTemplate;
	private Logger logger = Logger.getLogger(JndiSupport.class);

	public void setJndiTemplate(JndiTemplate jndiTemplate) {
		this.jndiTemplate = jndiTemplate;
	}
	
	public void bind(String name, Object object) {
		if(logger.isDebugEnabled()) {
			logger.debug("Binding jndi for entry " + name);
		}
		try {
			jndiTemplate.bind(name, object);
		} catch (NamingException e) {
			logger.error("Error while looking for jndi entry  " + name, e);
		}
	}
}